
//  马上发送请求  获取用户信息
axios.get('http://www.itcbc.com:8080/my/user/userinfo', {
  //键值
  headers: {
    Authorization: localStorage.getItem('token')
  }

}).then(res => {
  let { nickname, user_pic, username } = res.data.data;

  let name = nickname || username;
  $('.username').text(name);

  if (user_pic) {
    $('.layui-nav-img').attr('src', user_pic).show();
  } else {
    let first = name.substring(0, 1).toUpperCase();
    $('.user-avatar').text(first).css('display', 'inline-block')
  }

})

// ------------------------------  退出 --------------------------------------

$('#logout').on('click', function () {
  //  询问是否要退出
  layer.confirm('你确定要推出吗?', { icon: 3, title: '提示' }, function (index) {

    localStorage.removeItem('toten');

    location.href = './login.html'
    layer.close(index);
  })
})